﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProjetIntegrationMobilite
{
    class Game
    {
        private int k;
        private string _pseudoUser1;
        private string _pseudoUser2;
        PointsJeu[] petitPoint = new PointsJeu[81];

        public Game(string pseudoUser1, string pseudoUser2)
        {
            PseudoUser1 = pseudoUser1;
            PseudoUser2 = pseudoUser2;
        }

        #region get and set of game information
        public string PseudoUser1
        {
            get
            {
                if (_pseudoUser1.Length == 0)
                    throw new Exception("NomUser improperly initialized");
                return _pseudoUser1;
            }
            set
            {
                if (value == null || value.Length == 0)
                    throw new ArgumentException("NomUser cannot be null or empty");
                _pseudoUser1 = value;
            }
        }

        public string PseudoUser2
        {
            get
            {
                if (_pseudoUser2.Length == 0)
                    throw new Exception("NomUser improperly initialized");
                return _pseudoUser2;
            }
            set
            {
                if (value == null || value.Length == 0)
                    throw new ArgumentException("NomUser cannot be null or empty");
                _pseudoUser2 = value;
            }
        }
        #endregion

        public void CréationPlateauDeJeu()
        {
            #region Creating the game board
            for (int i = 0; i < 9; i++)
            {
                for (int j = 0; j < 9; j++)
                {
                    petitPoint[k] = new PointsJeu(j, i, 0);
                    k++;
                }
            }
            #endregion
        }

        public int PostionPoints(int X, int Y)
        {
            #region Positioning of the point
            for (int i = 0; i < 81; i++)
            {
                if (petitPoint[i].coordX == X && petitPoint[i].coordY == Y && petitPoint[i].choixPoint != 0)
                {
                    petitPoint[i].choixPoint = 1;
                    return 1;
                }
            }
            return 0;
            #endregion
        }
    }
}
